<?php
include"config.php";
	session_start();
	
if(isset($_REQUEST['user'])){
	if($_REQUEST['user'] == 'guest'){
		$_SESSION['username'] = 'guest';
		$_SESSION['password'] = 'guest';
?>
<script language="JavaScript">alert('Anda berhasil login Sebagai Guest');
document.location='app/index.php'</script>
<?php
	}
}

if(isset($_POST['login'])) {

	$username = $_POST['username'];
	$password = md5($_POST['password']);
	$sql = mysql_query("SELECT * FROM tbl_user WHERE username='$username' && password='$password'");
	$num = mysql_num_rows($sql);
if($num==1) {

$_SESSION['username'] = $username;
$_SESSION['password'] = $password;
?>

<script language="JavaScript">alert('Anda berhasil login');
document.location='app/index.php'</script>
<?php
} else {
?>

<script language="JavaScript">alert('Username & Password Salah');
document.location='index.php'</script><?php
}
}
?>